<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        /*
        函数功能：求某个数字所有约数之和
        输入：一个整数
        输出：输入数字的所有约数之和
        */
        function getDivisors(num){
            var sum = 0;

            for(var i=1; i<num; i++){
                if(num%i == 0){
                    console.log(i);
                    sum += i;
                }
            }
            
            console.log("约数之和："+sum);
        }

        var num = parseInt(prompt("请输入一个数字:"));
        getDivisors(num);

    </script>
</head>
<body>
    
</body>
</html>